#include "VertexBuffer.h"
#include "GraphicsDeviceManager.h"

VertexBuffer::VertexBuffer()
{
	// Generate a new Vertex Buffer and store ID
	glGenBuffersARB(1, &m_nID);
}

VertexBuffer::~VertexBuffer()
{
	// Delete the Vertex Buffer
	glDeleteBuffersARB(1, &m_nID);
}

void VertexBuffer::SetData(void* data, unsigned int size, BufferUsage bufferUsage)
{
	// Store number of vertices
	m_nVertexCount = size / sizeof(Vertex);

	glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_nID);
	glBufferDataARB(GL_ARRAY_BUFFER_ARB, size, data, bufferUsage);
	glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
}

const unsigned int VertexBuffer::GetID() const
{
	return m_nID;
}

const unsigned int VertexBuffer::GetVertexCount() const
{
	return m_nVertexCount;
}

const Vertex* VertexBuffer::GetData() const
{
	return m_pData;
}
